package com.tuojiahr.service.impl;

import java.util.Date;

import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.tuojiahr.common.HibernatePageCommon;
import com.tuojiahr.domain.TuoJiaHrUser;
import com.tuojiahr.service.UserService;

/**
 * 说明：
 *
 * @author wang.haibo
 * @date 2012-11-11 上午2:13:01
 */

@Transactional
public class UserServiceImpl extends HibernatePageCommon implements UserService {

	//登录
	@Override
	@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
	public TuoJiaHrUser loginUser(String name, String passWord) {
		return (TuoJiaHrUser) getSession()
				.createQuery("from TuoJiaHrUser u where u.name = ? and u.password = ?")
				.setParameter(0, name)
				.setParameter(1, passWord)
				.uniqueResult();
	}

	//修改密码
	@Override
	@Transactional(propagation=Propagation.REQUIRED)
	public void modifyPassword(TuoJiaHrUser user) {
		user.setUpdateTime(new Date());
		getHibernateTemplate().update(user);
	}

}
